package com.fau.template.service.impl;

import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.fau.template.entity.TLoginLog;
import com.fau.template.entity.TOperationLog;
import com.fau.template.service.ILogManagerService;
import com.fau.template.util.Page;

@Service
@Transactional(readOnly = true)
public class LogManagerServiceImpl extends BaseService implements ILogManagerService {

	@Override
	public Page findLoginLogsByPage(Map<String, Object> map, TLoginLog log) {
		
		return null;
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void addLoginLog(TLoginLog log) {
		this.iBaseDao.insertObject(log);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void deleteLoginLogs(TLoginLog log) {
		String[] ids = log.getId().split("-");
		for(String id : ids) {
			this.iBaseDao.updateByHql("delete from TLoginLog t where t.id = ? ", id);
		}
	}

	@Override
	public Page findOperationLogsByPage(Map<String, Object> map, TOperationLog log) {
		
		return null;
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void addOperationLog(TOperationLog log) {
		this.iBaseDao.insertObject(log);
	}

	@Override
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void deleteOperationLogs(TOperationLog log) {
		String[] ids = log.getId().split("-");
		for(String id : ids) {
			this.iBaseDao.updateByHql("delete from TOperationLog t where t.id = ? ", id);
		}
	}

}
